CREATE TABLE [dbo].[TASALD_EMPR]
(
[CO_EMPR] [dbo].[TD_VC_002] NOT NULL,
[CO_UNID_CNTB] [dbo].[TD_VC_003] NOT NULL,
[NU_CNTB_EMPR] [dbo].[TD_IN_001_CONT] NOT NULL,
[NU_ANNO] [dbo].[TD_IN_004_ANNO] NOT NULL CONSTRAINT [DF__TASALD_EM__NU_AN__0BC6C43E] DEFAULT (datepart(year,getdate())),
[NU_MESE] [dbo].[TD_IN_002_MESE] NOT NULL,
[CO_CNTA_EMPR] [dbo].[TD_VC_020_CNTA] NOT NULL,
[TI_AUXI_EMPR] [dbo].[TD_VC_001] NULL,
[CO_AUXI_EMPR] [dbo].[TD_VC_020] NULL,
[CO_ORDE_SERV] [dbo].[TD_VC_020] NULL,
[IM_CARG_CNTB] [dbo].[TD_NU_016_004] NOT NULL CONSTRAINT [DF__TASALD_EM__IM_CA__0F975522] DEFAULT ((0)),
[IM_ABON_CNTB] [dbo].[TD_NU_016_004] NOT NULL CONSTRAINT [DF__TASALD_EM__IM_AB__117F9D94] DEFAULT ((0)),
[IM_CARG_ORIG] [dbo].[TD_NU_016_004] NOT NULL CONSTRAINT [DF__TASALD_EM__IM_CA__1367E606] DEFAULT ((0)),
[IM_ABON_ORIG] [dbo].[TD_NU_016_004] NOT NULL CONSTRAINT [DF__TASALD_EM__IM_AB__15502E78] DEFAULT ((0)),
[PR_DATO] [dbo].[TD_VC_020] NULL,
[CO_USUA_CREA] [dbo].[TD_VC_008_USUA] NOT NULL,
[FE_USUA_CREA] [dbo].[TD_DT_001_SIST] NOT NULL CONSTRAINT [DF__TASALD_EM__FE_US__173876EA] DEFAULT (getdate()),
[CO_USUA_MODI] [dbo].[TD_VC_008_USUA] NOT NULL,
[FE_USUA_MODI] [dbo].[TD_DT_001_SIST] NOT NULL CONSTRAINT [DF__TASALD_EM__FE_US__182C9B23] DEFAULT (getdate())
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TASALD_EMPR] ADD CONSTRAINT [CK__TASALD_EM__CO_CN__0EA330E9] CHECK (([CO_CNTA_EMPR]>='0' AND [CO_CNTA_EMPR]<='99999999999999999999'))
GO
ALTER TABLE [dbo].[TASALD_EMPR] ADD CONSTRAINT [CK__TASALD_EM__IM_AB__1273C1CD] CHECK (([IM_ABON_CNTB]>=(0)))
GO
ALTER TABLE [dbo].[TASALD_EMPR] ADD CONSTRAINT [CK__TASALD_EM__IM_AB__164452B1] CHECK (([IM_ABON_ORIG]>=(0)))
GO
ALTER TABLE [dbo].[TASALD_EMPR] ADD CONSTRAINT [CK__TASALD_EM__IM_CA__108B795B] CHECK (([IM_CARG_CNTB]>=(0)))
GO
ALTER TABLE [dbo].[TASALD_EMPR] ADD CONSTRAINT [CK__TASALD_EM__IM_CA__145C0A3F] CHECK (([IM_CARG_ORIG]>=(0)))
GO
ALTER TABLE [dbo].[TASALD_EMPR] ADD CONSTRAINT [CK__TASALD_EM__NU_AN__0CBAE877] CHECK (([NU_ANNO]>=(0)))
GO
ALTER TABLE [dbo].[TASALD_EMPR] ADD CONSTRAINT [CK__TASALD_EM__NU_CN__0AD2A005] CHECK (([NU_CNTB_EMPR]>=(1) AND [NU_CNTB_EMPR]<=(99)))
GO
ALTER TABLE [dbo].[TASALD_EMPR] ADD CONSTRAINT [CK__TASALD_EM__NU_ME__0DAF0CB0] CHECK (([NU_MESE]>=(0) AND [NU_MESE]<=(13)))
GO
CREATE NONCLUSTERED INDEX [ITASALD_EMPR_02] ON [dbo].[TASALD_EMPR] ([CO_EMPR], [CO_UNID_CNTB], [NU_CNTB_EMPR], [NU_ANNO], [NU_MESE], [CO_CNTA_EMPR], [TI_AUXI_EMPR], [CO_AUXI_EMPR], [CO_ORDE_SERV]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [ITASALD_EMPR_03] ON [dbo].[TASALD_EMPR] ([CO_EMPR], [NU_CNTB_EMPR], [NU_ANNO], [NU_MESE], [CO_CNTA_EMPR], [TI_AUXI_EMPR], [CO_AUXI_EMPR]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [ITASALD_EMPR_01] ON [dbo].[TASALD_EMPR] ([CO_EMPR], [NU_CNTB_EMPR], [NU_ANNO], [NU_MESE], [TI_AUXI_EMPR], [CO_AUXI_EMPR]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TASALD_EMPR] ADD CONSTRAINT [FK1_TMPLAN_ANNO_A_TASALD_EMPR] FOREIGN KEY ([CO_EMPR], [CO_CNTA_EMPR]) REFERENCES [dbo].[TMPLAN_ANNO] ([CO_EMPR], [CO_CNTA_EMPR])
GO
ALTER TABLE [dbo].[TASALD_EMPR] ADD CONSTRAINT [FK1_TTCNTB_EMPR_A_TASALD_EMPR] FOREIGN KEY ([CO_EMPR], [NU_CNTB_EMPR]) REFERENCES [dbo].[TTCNTB_EMPR] ([CO_EMPR], [NU_CNTB_EMPR])
GO
